<html>
<head><meta charset="utf-8"><title>Attributes on function parameters · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20on.20function.20parameters.html">Attributes on function parameters</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230727956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20on%20function%20parameters/near/230727956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20on.20function.20parameters.html#230727956">(Mar 17 2021 at 16:59)</a>:</h4>
<p>I'm debugging a parser bug where <code>#[attrs]</code> on the first function parameter get attached to the <code>PARAM_LIST</code> instead of the <code>PARAM</code> node.</p>
<p>This is because <a href="https://github.com/rust-analyzer/rust-analyzer/blob/0a6471384529bd8861c628756695c52be4c6837f/crates/parser/src/grammar/params.rs#L51-L52">this branch</a> calls <code>Marker::abandon</code>, which puts the attributes on the <code>PARAM_LIST</code> parent node.</p>
<p>What would be the best way to fix this?</p>



<a name="230729200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20on%20function%20parameters/near/230729200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20on.20function.20parameters.html#230729200">(Mar 17 2021 at 17:05)</a>:</h4>
<p>Probably returning the marker on failure instead and then continue with it in the loop?</p>



<a name="230729433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20on%20function%20parameters/near/230729433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20on.20function.20parameters.html#230729433">(Mar 17 2021 at 17:07)</a>:</h4>
<p>Ye looks like this is whats done in other places as well <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/parser/src/grammar/items.rs#L87">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/parser/src/grammar/items.rs#L87</a></p>



<a name="230729614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20on%20function%20parameters/near/230729614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20on.20function.20parameters.html#230729614">(Mar 17 2021 at 17:08)</a>:</h4>
<p>looks good, I'll try that</p>



<a name="230730989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20on%20function%20parameters/near/230730989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20on.20function.20parameters.html#230730989">(Mar 17 2021 at 17:16)</a>:</h4>
<p>looks like it worked, thanks!</p>



<a name="230745660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Attributes%20on%20function%20parameters/near/230745660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Attributes.20on.20function.20parameters.html#230745660">(Mar 17 2021 at 18:44)</a>:</h4>
<p>might make sense to compaer this with other attr lists (like fields and such)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>